package org.example.recruitserver.mapper;

import net.sf.jsqlparser.Model;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.recruitserver.model.AJobListModel;
import org.example.recruitserver.model.AdderNameModel;
import org.example.recruitserver.model.ProvinceModel;

import java.util.List;

@Mapper
public interface RecruitListMapper {

    // 根据ID查询数据
    @Select("select * from a_job_list where aJob_Id =#{id}")
    AJobListModel findId(int id);

    // 查询省份岗位数量
    @Select("SELECT SUBSTRING_INDEX(aJob_adder, '·', 1) AS adderName, COUNT(*) AS numberSize FROM a_job_list WHERE aJob_adder IS NOT NULL AND aJob_adder != '' GROUP BY adderName")
    public List<AdderNameModel> findAll();

    // 获取省名
    @Select("select * from dou_area where area_id <= #{numberCount}")
    public List<ProvinceModel> findProvinceAll(int numberCount);

    // 模糊查询
    @Select("SELECT * FROM dou_area WHERE name LIKE CONCAT('%', #{name}, '%')")
    public List<ProvinceModel> findLikeProvinceAll(String name);

    // 根据语言获取相关岗位列表
    @Select("SELECT * FROM a_job_list where a_job_list.aJob_language_type = #{TypeName} LIMIT ${page}, #{pageSize}")
    public List<AJobListModel> findTypeAll(String TypeName, int page, int pageSize);

    // 根据用户输入岗位名称查询岗位列表
    @Select("select * from a_job_list where aJob_name LIKE CONCAT('%', #{rName}, '%')")
    public List<AJobListModel> findAllLikeRecruit(String rName);
}
